package main

import (
	"fmt"
	"reflect"
)

func main() {
	fmt.Println("vim -go")
	var a int
	var b int = 1
	var c = 1
	fmt.Println(a,b,c)
	d := 1
	msg := "hello"
	fmt.Println(d, msg)
	e := 3.14
	fmt.Println(reflect.TypeOf(e))
	fmt.Println(reflect.TypeOf(msg))
	fmt.Println(int(e))
	//指针
	var p *string
	p = &msg
	fmt.Println(p)
	//修改指针指向对象的值
	*p = "hello"
	fmt.Println(*p)
	fmt.Println(msg)
	num := 100
	add(num)
	fmt.Println(num)
	realadd(&num)
	fmt.Println(num)
	fmt.Println(add2(1,2))
	fmt.Println(add3(3,1))
	add4(1,2,3,4,5)
}


func add(num int){
	num += 1
}


func realadd(num *int){
	*num += 1
}


func add2(num1 int, num2 int) (int, int){
	return num1+num2, 100
}

func add3(num1 int, num2 int) (ans int, ans2 int){
	ans = num1+num2
	ans2 = num1-num2
	return
}

func add4(nums ...int){
	fmt.Println(reflect.TypeOf(nums))
	fmt.Println(len(nums))
	fmt.Println(nums)

	sum := 0
	for i := 0; i < len(nums); i++ {
		sum += nums[i]
	}
	fmt.Println(sum)
}
